<template>
	<view class="container">
		<view class="tab_box">
			<u-tabs :list="list" :is-scroll="false" :current="current" @change="change" active-color="#EA3D37"
				bar-height="6" bar-width="40"></u-tabs>
		</view>
		<view class="content">
			<view class="list" v-for="(item,index) in couponList" :key="index" @click="selectClick(item)">
				<view class="kuang" :class="current >0?'gray':''">
					<view>
						<text>￥</text>
						<text class="big">{{item.coupon_price}}</text>
					</view>
				</view>
				<view class="text">
					<view class="big">满{{item.use_min_price}}元减{{item.coupon_price}}元</view>
					<view class="small">有效期：{{item.end_time}}</view>
				</view>
				<view class="btns" v-if="item._msg == '未使用'">待使用</view>
				<view class="gray_txt" v-if="item._msg == '已过期'">已过期</view>
				<view class="gray_txt" v-if="item._msg == '已使用'">已使用</view>
			</view>
		</view>
		<!-- <u-loadmore :status="status" /> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					name: '全部'
				}, {
					name: '未使用'
				}, {
					name: '已使用'
				}],
				current: 0,
				couponList: [],
				total: 1,
				count: 1,
				status: 'loadmore'
			}
		},
		onLoad() {
			this.getData()
		},
		onReachBottom() {
			if (this.page >= this.count) return this.status = 'nomore';
			this.status = 'loading';
			this.page = ++this.page;
			this.getData()
		},
		methods: {
			getData() {
				this.$allApi.userCouponList({
					types: this.current,
				}).then(res => {
					this.couponList = res.data
				})
			},
			change(index) {
				this.current = index;
				this.couponList = []
				this.page = 1
				this.getData()
			},
		}
	}
</script>

<style scoped lang="scss">
	.content {
		padding: 20rpx 20rpx;
	}

	.list {
		display: flex;
		align-items: center;
		justify-content: space-between;
		background: #fff;
		width: 710rpx;
		height: 210rpx;
		box-shadow: 0rpx 4rpx 7rpx 1rpx rgba(100, 100, 100, 0.14);
		margin-bottom: 20rpx;
		border-radius: 20rpx;
		overflow: hidden;

		.text {
			flex: 1;
			padding-left: 20rpx;

			.big {
				font-size: 32rpx;
				font-weight: bold;
			}

			.small {
				font-size: 20rpx;
				margin-top: 12rpx;
			}
		}

		.btns {
			width: 160rpx;
			height: 62rpx;
			border-radius: 32rpx;
			background: #FFFFFF;
			border: 2rpx solid #EA3D37;
			color: #EA3D37;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-right: 24rpx;
		}

		.gray_txt {
			width: 160rpx;
			height: 62rpx;
			border-radius: 32rpx;
			background: #FFFFFF;
			color: #999999;
			border: 2rpx solid #999999;
			display: flex;
			align-items: center;
			justify-content: center;
			margin-right: 24rpx;

		}

		.kuang {
			width: 210rpx;
			height: 210rpx;
			background: linear-gradient(92.49deg, #F88E87 0%, #EA3D37 100%);
			border-right: 4rpx dashed #EA3D37;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 32rpx;
			color: #fff;

			.big {
				font-size: 72rpx;
				font-weight: bold;
			}
		}

		.gray {
			background: #B0B0B0;
			border-right: 4rpx dashed #B0B0B0;
		}
	}

	.container {
		min-height: 100vh;
		background: #F8F8F8;
	}

	.tab_box {
		width: 750rpx;
		height: 100rpx;
		background: #FFFFFF;
		box-shadow: 0rpx 1rpx 0rpx #F2F0F0;
	}
</style>